{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Examples and Exercises from Think Stats, 2nd Edition\n",
    "\n",
    "http://thinkstats2.com\n",
    "\n",
    "Copyright 2016 Allen B. Downey\n",
    "\n",
    "MIT License: https://opensource.org/licenses/MIT\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "from __future__ import print_function, division\n",
    "\n",
    "%matplotlib inline\n",
    "\n",
    "import numpy as np\n",
    "\n",
    "import nsfg\n",
    "import first"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Given a list of values, there are several ways to count the frequency of each value."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "t = [1, 2, 2, 3, 5]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "You can use a Python dictionary:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{1: 1, 2: 2, 3: 1, 5: 1}"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "hist = {}\n",
    "for x in t:\n",
    "    hist[x] = hist.get(x, 0) + 1\n",
    "    \n",
    "hist"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "You can use a `Counter` (which is a dictionary with additional methods):"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Counter({1: 1, 2: 2, 3: 1, 5: 1})"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from collections import Counter\n",
    "counter = Counter(t)\n",
    "counter"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Or you can use the `Hist` object provided by `thinkstats2`:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Hist({1: 1, 2: 2, 3: 1, 5: 1})"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import thinkstats2\n",
    "hist = thinkstats2.Hist([1, 2, 2, 3, 5])\n",
    "hist"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "`Hist` provides `Freq`, which looks up the frequency of a value."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "hist.Freq(2)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "You can also use the bracket operator, which does the same thing."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "hist[2]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "If the value does not appear, it has frequency 0."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "hist[4]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "The `Values` method returns the values:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "dict_keys([1, 2, 3, 5])"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "hist.Values()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "So you can iterate the values and their frequencies like this:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1 1\n",
      "2 2\n",
      "3 1\n",
      "5 1\n"
     ]
    }
   ],
   "source": [
    "for val in sorted(hist.Values()):\n",
    "    print(val, hist[val])"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Or you can use the `Items` method:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1 1\n",
      "2 2\n",
      "3 1\n",
      "5 1\n"
     ]
    }
   ],
   "source": [
    "for val, freq in hist.Items():\n",
    "     print(val, freq)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "`thinkplot` is a wrapper for `matplotlib` that provides functions that work with the objects in `thinkstats2`.\n",
    "\n",
    "For example `Hist` plots the values and their frequencies as a bar graph.\n",
    "\n",
    "`Config` takes parameters that label the x and y axes, among other things."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYwAAAEKCAYAAAAB0GKPAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvOIA7rQAAFdlJREFUeJzt3XuwZWV95vHvkwbUKFG0j8rQNI01aIlGUU5hHKoUJoqNMYIJGZuogxZOTzngJZeZgeiIg5lUTGp0SiHBTuygGaUTL2TaDIIdQRmDKKexBRtC6CAJZ5qZbm1ECJak8Td/7NVT28O5vH1Zex/6fD9Vu3qt933X2r9dVPGcdXtXqgpJkhbyU+MuQJL02GBgSJKaGBiSpCYGhiSpiYEhSWpiYEiSmhgYkqQmBoYkqYmB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GRVfW7c9YxDVX0f+DKDKfsPZicDr+3O5W8A/mWS/z7ekkanqrZ3/+4AruQgmmnbwFDvugu/HwNur6oPjrueUUoykeQp3fITgFcAfzPeqvpVVRdW1YqqWsVg9oZrq+qNYy5rJJI8sbuxgyRPBE4DDpo7Ig2MEUtyBfA14DlJppOcO+6aRuBk4E0M/tLc0n1ePe6iRuRI4LoktzCYX21TVS2p20yXmGcAX03yLQbz3/3Pqrp6zDUdMN5WK0lq4hGGJKmJgSFJamJgSJKaGBiSpCYGhiSpiYEh9SzJgwuPkhY/A0OS1MTAkPZSkg8k+XdD6+9LclGSLyW5uXsXwhmzbHfK8LshklyS5M3d8olJvtJNWHdNNyW8tKgYGNLe2wC8fmj9XwF/Aryum3TuVOC/dlOiLKibZ+sjwFlVdSKwHvgvB7Zkaf8dMu4CpMeaqvpmkqcn+WfABHAfcC/woW5m0h8zeN/HM4D/07DL5wDPBzZ1GbOs25+0qBgY0r75DHAW8EwGRxxvYBAeJ1bVP3UztT5+xja7+cmj+j39AbZW1Ut7rVjaT56SkvbNBgYzsZ7FIDyezOAdEP+U5FTgmFm2+Xvg+CSPS/Jk4Oe79juAiSQvhcEpqiTP6/0XSHvJIwxpH1TV1m4a6/9dVfcm+STw+SRTwBZmmcK8qu5J8ufALcCdwDe79oeTnAV8uAuSQxi8sW7riH6O1MTZaiVJTTwlJUlqYmBIkpoYGJKkJgaGJKmJgSFJamJgSJKaGBiSpCYGhiSpyf8DWViKI8ZxllAAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "import thinkplot\n",
    "thinkplot.Hist(hist)\n",
    "thinkplot.Config(xlabel='value', ylabel='frequency')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "As an example, I'll replicate some of the figures from the book.\n",
    "\n",
    "First, I'll load the data from the pregnancy file and select the records for live births."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [],
   "source": [
    "preg = nsfg.ReadFemPreg()\n",
    "live = preg[preg.outcome == 1]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Here's the histogram of birth weights in pounds.  Notice that `Hist` works with anything iterable, including a Pandas Series.  The `label` attribute appears in the legend when you plot the `Hist`. "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAY4AAAEKCAYAAAAFJbKyAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvOIA7rQAAHWBJREFUeJzt3X+cVXW97/HX2+HHaGAioBeBGlQ0DZVwFBL1+uNYaJ7I1MJTSF070zXtx6m8aXY1O3ov99Yp61gWKkc8KRw0KzRNyTDkHOKHiAiSx0kRJrgyihhGktDn/rG+g9thz8xew+zZe+D9fDz2Y6/92Wut/dkDM++9fuzvUkRgZmZWqn0q3YCZmfUsDg4zM8vFwWFmZrk4OMzMLBcHh5mZ5eLgMDOzXBwcZmaWi4PDzMxycXCYmVkuvSrdQDkMGjQo6urqKt2GmVmP8vjjj78UEYM7mm+PDI66ujqWLl1a6TbMzHoUSS+UMp93VZmZWS4ODjMzy8XBYWZmueyRxzjMrOd54403aGpq4vXXX690K3u82tpahg0bRu/evTu1vIPDzKpCU1MT/fv3p66uDkmVbmePFRG8/PLLNDU1MWLEiE6tw7uqzKwqvP766wwcONChUWaSGDhw4G5t2Tk4zKxqODS6x+7+nB0cZmaWS9mOcUiqBeYDfdPr3BMR10oaAcwCDgSWAZMj4i+S+gJ3AMcDLwMfjYg1aV1XAZcAO4DPRcRD5erbzKrD5dfP7NL13fS1i7p0fXuzch4c3wacERGvSeoNL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u/L00IYDI7vGSot1EfHvafrHwMlkWwXPR8R/pvqM1HtHfhER2yLiJbKBCg9O7/enEbE1st1jhWOxrSAbouXjZKPPtthINpKv7SV6VboBs1JFxMK022Vwkaf/1MHi2wqmd1D8//5jZFd3fAP4FdlV02rIPtXvA2yOiNHtvEZHQ1KX0kNr2yXtExEt1zNpPUZQdPC623lzl3TrS9C21U9b4xB9gCyQPgj8T0nvToFbC/y5nR5sD+MtDusx0jGFGrLdKu3ZQjbYXV7zgS8ACyOiGRgIvAtYlT59Py/pwtSLJB1XuHBEvAJskTQulUq95OsbyobFL+YZsotOtXiH3rw2+kXAArLdeHWSDk/1ycBv0vQast1PAOeX0Mt84DxJ+0rqD/wtgKR9yHatzSO7MNcBQL+0zBFku+hsL+HgsGrXcuB4OfBvZCN47uhgmRVkn9SfLDg4XopFZLtr5hesZ0VEtHwC/xhwiaQngVUUv2zwJcA0SQvJtgReLeF1pwEr2jg4/guyYzYtVgNTlI3oeyDZhaheBz5JthvtKbLrKrSMDHsd8F1Jj5FtVbQrsksQ/xvZcaWfkG2FQRbYP07rfwL4Trx5qd3TU5+2l/DouGZdSFK/iHgtTV8JDImIz+/G+oYAd0TEWcouC3x/RIzqkma7gKSDgbsi4sxK92Ldx8c4zLrWByRdRfa79QLZ2VSdFhEbJN1SqS8AluAdwJcq3YR1L29xmJlZLj7GYWZmuTg4zMwsFweHmZnl4uAwM7NcHBxmZpaLg8PMzHL5/9Sesj4iouyOAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "hist = thinkstats2.Hist(live.birthwgt_lb, label='birthwgt_lb')\n",
    "thinkplot.Hist(hist)\n",
    "thinkplot.Config(xlabel='Birth weight (pounds)', ylabel='Count')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Before plotting the ages, I'll apply `floor` to round down:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [],
   "source": [
    "ages = np.floor(live.agepreg)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYgAAAEKCAYAAAAIO8L1AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvOIA7rQAAGAlJREFUeJzt3X+w1fV95/HnO4qCxogougq60A0aTaJoLog1kyA4RKVTcBJiYmpIhg3pRFNjOmmMu5lqtRPTcWvqJqMlakVjE63GxbomraKYWUdEUGuNmEhdhbtaofg7Sgz43j/O5+rx8r33HvB+7zkXno+ZM+f7/ZzPOed9v8O9Lz6f76/ITCRJ6u097S5AktSZDAhJUiUDQpJUyYCQJFUyICRJlQwISVIlA0KSVMmAkCRVMiAkSZV2bXcB78Z+++2XEyZMaHcZkjSsrFq16j8yc+xA/YZ1QEyYMIGVK1e2uwxJGlYi4ulW+jnFJEmqZEBIkioZEJKkSsN6H4Skncfvfvc7uru72bRpU7tLGTZGjhzJ+PHjGTFixHa934CQNCx0d3ez1157MWHCBCKi3eV0vMxk48aNdHd3M3HixO36DKeYJA0LmzZtYt999zUcWhQR7Lvvvu9qxGVASBo2DIdt8263lwEhSarkPghJw9JZF/14UD/v+//9s4P6eTsCA0JtMdAvt7+s2tlt2bKFXXbZpa01OMUkSdtg7ty5fOQjH+GDH/wgixYtAuCqq67i0EMPZfr06XzpS1/irLPOAmDDhg188pOfZMqUKUyZMoV7770XgPPPP58zzjiDGTNmMGnSJH74wx8CsGzZMk444QROP/10PvzhDwPwox/9iKlTpzJ58mS+/OUvs2XLln6/czA5glAt+hshODrQcHb11VczZswYXn/9daZMmcLs2bO58MILefDBB9lrr72YMWMGRx11FABnn30255xz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oOpTJvexWwOjP/uumljtu+fdXawdt2bESMLsujgBNp7De5G/hU6dYR2xb6rPfxpv8oBI05/bZv38z8VmaOz8wJNC7zc1dmfo4O3bZ91PtHg71tO+pM6qESET8GpgP7RUQ38OfAxcCNEbEAWAvMa1+F79RHvdPLIWwJPAV8uW0FvtPxwBnAv5a5Z4Dz6Mzt21etn+3QbXsgsDgaN9d6D3BjZt4WEY8BP4mIi4CHaIReJ+ir3rsiYiyNKZyHgT9uZ5ED+CaduW37cv1gblvPpJYkVXKKSZJUyYCQJFUyICRJlQwISVIlA0KSVMmAkCRVMiCkNijnBkgdzYCQBhARF/bcK6Ks/2VE/ElEfCMiHigXRrug6fX/FRGryj0QFja1vxoRfxER9wPHRcTFEfFYef8lQ/xjSQPyRDlpAOVKrz/NzGMi4j3AEzTOuJ5J4yzroHEpkb/KzF9ExJjMfL5cXuIB4OOZuTEiEjgtM2+MiDHAfcAHMjMjYnS5XpHUMXbKS21I2yIzn4qIjRFxNHAAjUsuTAFmlWWA9wKTgF8AfxIRp5b2g0v7RmALjQsDArwMbAKujIj/Ddw2FD+LtC0MCKk1VwJfAP4TcDWN0cN3MvNvmztFxHQaF6U7LjNfi4hlwMjy8qbM3AKQmZsjYmr5nM8AZ9G4gqjUMQwIqTW3AH9B465op9O4XemFEXF9Zr4aEeOA3wF7Ay+UcPgAjctxb6Xcg2KPzLw9IpYDa4bkp5C2gQEhtSAz34iIu2ncYWwL8M8RcThwX+PKyrwK/BHwc+CPI+IR4FfA8j4+ci9gSUSMpLEP45y6fwZpW7mTWmpB2Tn9IDAvM59odz3SUPAwV2kAEXEEjSmgpYaDdiaOICRJlRxBSJIqGRCSpEoGhCSpkgEhSapkQEiSKhkQkqRK/x/uHLXxCvUFxQAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "hist = thinkstats2.Hist(ages, label='agepreg')\n",
    "thinkplot.Hist(hist)\n",
    "thinkplot.Config(xlabel='years', ylabel='Count')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "As an exercise, plot the histogram of pregnancy lengths (column `prglngth`)."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAY4AAAEKCAYAAAAFJbKyAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvOIA7rQAAFldJREFUeJzt3XuQnXWd5/H3lxBINoRb0liYZOmocQwyC0JzETIWghuiIGEt0CiOEbNGWRhlnBlXZtlCBEqsYgaduOimDJvgxiAILlcXslzU7IRLIIhAYMlgDF1QJMNFQ1FhEua7f5ynwyH07Rf6nNN9+v2qSp3n+T2X/v6aw/n0czm/JzITSZIGa7dWFyBJGlkMDklSEYNDklTE4JAkFTE4JElFDA5JUhGDQ5JUxOCQJBUxOCRJRXZvdQGNMHny5Ozs7Gx1GZI0ojz44IP/nJkdA63XlsHR2dnJmjVrWl2GJI0oEfH7waznqSpJUhGDQ5JUxOCQJBVpy2scvdm2bRvd3d1s3bq11aWMKOPGjWPq1KmMHTu21aVIGiZGTXB0d3czceJEOjs7iYhWlzMiZCYvvPAC3d3dTJ8+vdXlSBomRs2pqq1btzJp0iRDo0BEMGnSJI/SJL3JqAkOwNDYBf7OJO1sVAWHJOntGzXXOHZ27iUrhnR/37/g00O6v97cc889XH755dxyyy27tP3SpUuZPXs273znO4E3vig5efLkoSxTUpsbtcExXL3++uuMGTOmIfteunQphxxyyI7gkEaq3v7wa8Yfb6oxOJpow4YNzJkzh6OPPpq1a9fy3ve+l6uvvpqDDz6YL3zhC9xxxx2ce+65vPvd72bBggVMmDCBWbNm8Ytf/IJHH330Tfv65je/ycaNG3n66afZuHEj5513Hl/5ylcAuPjii1m+fDnTpk1j8uTJHHHEETuOLs4880zGjx/P6tWrAVi0aBE333wz27Zt47rrruN973tf038vkkYWr3E02ZNPPsnChQt55JFH2HvvvbnyyiuB2vclVq1axbx58zjrrLP44Q9/yOrVq/s9+njiiSe4/fbbuf/++7nooovYtm0ba9as4frrr2ft2rXccMMNO8bsOv300+nq6mL58uU8/PDDjB8/HoDJkyfz0EMPcfbZZ3P55Zc3/hcgacQzOJps2rRpHHfccQB89rOfZdWqVQB86lOfAuDll19my5YtHHvssQB85jOf6XNfJ598MnvuuSeTJ0/mgAMO4Pnnn2fVqlXMnTuX8ePHM3HiRD7+8Y/3W88nPvEJAI444gg2bNjwdrsnaRQwOJps59tbe+YnTJgA1L50N1h77rnnjukxY8awffv2ou3r99GzvSQNxOBoso0bN+64vrBixQpmzZr1puX77bcfEydO5N577wXgmmuuKdr/rFmzuPnmm9m6dSuvvPIKt956645lEydOZMuWLW+zB5JGu1F7cbxVd2DMnDmTZcuW8aUvfYkZM2Zw9tlns2jRojets2TJEr74xS8yYcIEjj/+ePbZZ59B7//II4/k1FNP5dBDD+Wggw6iq6trx/af//zn+fKXv/ymi+OSVCpKT22MBF1dXbnzg5zWrVvHzJkzW1RRzYYNGzjllFPecofUzl555RX22msvAC677DKee+45vve97w365/Rs/+qrr/KhD32IxYsXc/jhh+9y3cPhdyfV83bcxoiIBzOza6D1Ru0Rx3B266238u1vf5vt27dz0EEHsXTp0qLtFy5cyOOPP87WrVuZP3/+2woNSdqZwdFEnZ2dAx5tQO0Oq567rHbFT37yk13eVpIGMqoujrfjablG83cmaWejJjjGjRvHCy+84AdhgZ7ncYwbN67VpUgaRkbNqaqpU6fS3d3N5s2bW13KiNLzBEBJ6jFqgmPs2LE+xU6ShsCoOVUlSRoaBockqYjBIUkqYnBIkooYHJKkIgaHJKmIwSFJKmJwSJKKGBySpCIGhySpiMEhSSpicEiSihgckqQiDQ+OiBgTEWsj4pZqfn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gt6DXiIWoD8GbXxgg4G/m81+u4ewGrgT4BDqI1kCrXhQJ6r2+d/pzY0SE+YPA28KyIWAbcCdzS4T9KgGRxSoczcVo3Eehbwj8AjwIeBdwO/A1Zm5qfrt4mIPwUey8wP9rHbfwQ+HBF/l5lbM/OliDgUOAk4B/gk8IWGdEgq5Kkqadf8Cvjr6vXXwJeBh4F7geMi4j0AEfFvIuK9wJNAR0R8sGofGxHvr9vfEuA24LqI2D0iJgO7Zeb1wH8FDm9Sv6QBGRzSrvk1cCCwOjOfB7YCv87MzcDngRUR8Qi1IHlf9Qji04HvRMRvqIXMsfU7rIZ8fwj4MbWn1d1TPcVvKXB+MzolDYaj40qSinjEIUkqYnBIkooYHJKkIgaHJKmIwSFJKmJwSJKKGBySpCIGhySpyP8HN69uxr1bHyEAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Solution\n",
    "\n",
    "hist = thinkstats2.Hist(live.prglngth, label='prglngth')\n",
    "thinkplot.Hist(hist)\n",
    "thinkplot.Config(xlabel='weeks', ylabel='Count')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "`Hist` provides smallest, which select the lowest values and their frequencies."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0 1\n",
      "4 1\n",
      "9 1\n",
      "13 1\n",
      "17 2\n",
      "18 1\n",
      "19 1\n",
      "20 1\n",
      "21 2\n",
      "22 7\n"
     ]
    }
   ],
   "source": [
    "for weeks, freq in hist.Smallest(10):\n",
    "    print(weeks, freq)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Use `Largest` to display the longest pregnancy lengths."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "50 2\n",
      "48 7\n",
      "47 1\n",
      "46 1\n",
      "45 10\n",
      "44 46\n",
      "43 148\n",
      "42 328\n",
      "41 587\n",
      "40 1116\n"
     ]
    }
   ],
   "source": [
    "# Solution\n",
    "\n",
    "for weeks, freq in hist.Largest(10):\n",
    "    print(weeks, freq)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "From live births, we can selection first babies and others using `birthord`, then compute histograms of pregnancy length for the two groups."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {},
   "outputs": [],
   "source": [
    "firsts = live[live.birthord == 1]\n",
    "others = live[live.birthord != 1]\n",
    "\n",
    "first_hist = thinkstats2.Hist(firsts.prglngth, label='first')\n",
    "other_hist = thinkstats2.Hist(others.prglngth, label='other')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "We can use `width` and `align` to plot two histograms side-by-side."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAY4AAAEKCAYAAAAFJbKyAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvOIA7rQAAGX5JREFUeJzt3X+01XW95/HnW0BxkhlRqYWiA3YdU2kiPKFFpdWkYndptrSyVkHWcCstzTtdKe+Md+q6lrOWGmlK4zXCrprZD9PrpYwMFctMUFIITSDKk6SkYZZZ4rznj/05uoN99jlfOPvH4Twfa+21v/vz/Xy++302X87rfH/s7zcyE0mSBmuXThcgSRpeDA5JUiUGhySpEoNDklSJwSFJqsTgkCRVYnBIkioxOCRJlRgckqRKRne6gFbYZ599cvLkyZ0uQ5KGlRUrVvw2MycM1G+nDI7JkyezfPnyTpchScNKRPxyM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qWAVczYtnMr1Qb3l9Wvk3WAt8oFP1lnm3sdUfMp3+fLeqpf4XW1euv03q7cr1t0m9HV1//ea4JKmSnfIYhySpdQwOSVIlBockqRKDQ5JUicEhSarE4JC6QETcFhHD5v7WGtkMDklSJQaHtB0i4h8i4uNl+nMR8YMy/ZaIuDoijomIuyLi3oj4erl2GhFxeETcXi6ieUtETNxqubtExFUR8c/lYoeLyj0iHoiIT7T/J5W2ZXBI2+cOaldahtq3dfco10h7PbVv9P4j8N+ydsHM5cDZZf6l1O6jcDiwEDi/bpmjgWuAn2fmPwLTgP0yc2pmvpLaNYmkjhs9cBdJDawADi/3x/gzcC+1AHkDcBO1mxT9sHZrCnYF7gIOBqYCS0r7KGBj3TL/L3B9ZvaFyXrgwIi4lNqFDb/X4p9JGhSDQ9oOmflcuWLpB6hdHO9+4E3Ay6ldTG5JZp5aPyYiXgmszszX9rPYHwFvioiLMvPZzPxdRLyK2g15Tqd2A7LTWvIDSRW4q0rafncA/6M8L6N29dqVwI+BmRHxNwAR8R8i4r9Qu5DfhIh4bWkfExGH1S3vS8Bi4OsRMToi9gF2ycxvAv8TmN6mn0tqyuCQtt8yave4vyszHwOeBZZl5iZgDvDViLifWpC8IjP/ApwM/J+I+Cm1kHld/QIz82Jqu73+ldrd2m4rdwNcRO3mPVLHeXVcSVIlbnFIkioxOCRJlRgckqRKDA5JUiUGhySpEoNDklSJwSFJqsTgkCRV8v8B9Up3XC4FdlUAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "width = 0.45\n",
    "thinkplot.PrePlot(2)\n",
    "thinkplot.Hist(first_hist, align='right', width=width)\n",
    "thinkplot.Hist(other_hist, align='left', width=width)\n",
    "thinkplot.Config(xlabel='weeks', ylabel='Count', xlim=[27, 46])"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "`Series` provides methods to compute summary statistics:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {},
   "outputs": [],
   "source": [
    "mean = live.prglngth.mean()\n",
    "var = live.prglngth.var()\n",
    "std = live.prglngth.std()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Here are the mean and standard deviation:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(38.56055968517709, 2.702343810070593)"
      ]
     },
     "execution_count": 23,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "mean, std"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "As an exercise, confirm that `std` is the square root of `var`:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "True"
      ]
     },
     "execution_count": 24,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Solution\n",
    "\n",
    "np.sqrt(var) == std"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Here's are the mean pregnancy lengths for first babies and others:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(38.60095173351461, 38.52291446673706)"
      ]
     },
     "execution_count": 25,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "firsts.prglngth.mean(), others.prglngth.mean()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "And here's the difference (in weeks):"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0.07803726677754952"
      ]
     },
     "execution_count": 26,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "firsts.prglngth.mean() - others.prglngth.mean()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "This functon computes the Cohen effect size, which is the difference in means expressed in number of standard deviations:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {},
   "outputs": [],
   "source": [
    "def CohenEffectSize(group1, group2):\n",
    "    \"\"\"Computes Cohen's effect size for two groups.\n",
    "    \n",
    "    group1: Series or DataFrame\n",
    "    group2: Series or DataFrame\n",
    "    \n",
    "    returns: float if the arguments are Series;\n",
    "             Series if the arguments are DataFrames\n",
    "    \"\"\"\n",
    "    diff = group1.mean() - group2.mean()\n",
    "\n",
    "    var1 = group1.var()\n",
    "    var2 = group2.var()\n",
    "    n1, n2 = len(group1), len(group2)\n",
    "\n",
    "    pooled_var = (n1 * var1 + n2 * var2) / (n1 + n2)\n",
    "    d = diff / np.sqrt(pooled_var)\n",
    "    return d"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Compute the Cohen effect size for the difference in pregnancy length for first babies and others."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0.028879044654449883"
      ]
     },
     "execution_count": 28,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Solution\n",
    "\n",
    "CohenEffectSize(firsts.prglngth, others.prglngth)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "collapsed": true
   },
   "source": [
    "## Exercises"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Using the variable `totalwgt_lb`, investigate whether first babies are lighter or heavier than others. \n",
    "\n",
    "Compute Cohen’s effect size to quantify the difference between the groups.  How does it compare to the difference in pregnancy length?"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(7.201094430437772, 7.325855614973262)"
      ]
     },
     "execution_count": 29,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Solution\n",
    "\n",
    "firsts.totalwgt_lb.mean(), others.totalwgt_lb.mean()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "-0.088672927072602"
      ]
     },
     "execution_count": 30,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Solution\n",
    "\n",
    "CohenEffectSize(firsts.totalwgt_lb, others.totalwgt_lb)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "For the next few exercises, we'll load the respondent file:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "metadata": {},
   "outputs": [],
   "source": [
    "resp = nsfg.ReadFemResp()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Make a histogram of <tt>totincr</tt> the total income for the respondent's family.  To interpret the codes see the [codebook](http://www.icpsr.umich.edu/nsfg6/Controller?displayPage=labelDetails&fileCode=FEM&section=R&subSec=7876&srtLabel=607543)."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAY4AAAEKCAYAAAAFJbKyAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvOIA7rQAAGfNJREFUeJzt3XuUFeWd7vHvYzeCF7xw0RgaA06ImhARp2WMZrwxyXg74syRicZRUM5hnUSNCTmOOGaOrpmYRRInqHESh/ECzKCRqInocTSKEDVGY+PBK0aJGmllpAUxOI5RzO/8UW/Dttl9qbb3rr27n89ae3XVW29V/XbT9NNVb+0qRQRmZmY9tV3RBZiZWX1xcJiZWS4ODjMzy8XBYWZmuTg4zMwsFweHmZnl4uAwM7NcHBxmZpaLg8PMzHJprNSGJV0HnACsi4jxqe27wH8D3gV+A5wZERvTsguBGcD7wFci4u7Ufgxw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
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Solution\n",
    "\n",
    "hist = thinkstats2.Hist(resp.totincr)\n",
    "thinkplot.Hist(hist, label='totincr')\n",
    "thinkplot.Config(xlabel='income (category)', ylabel='Count')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Make a histogram of <tt>age_r</tt>, the respondent's age at the time of interview."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYgAAAEKCAYAAAAIO8L1AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvOIA7rQAAF3FJREFUeJzt3X2wHXWd5/H3B4gJCAOERCYkMMmukZGxIDoXxMEHBi1E3RLYEQfKVWZkJ1oDIzqWO8jultlCdmRXBZUtqCisgA+IIoouPgDyUOwAEjAiElRGkVyhSAQEXAQNfPeP0xePoXNzk9zOOTf3/ao6dU7/zq/7fDsN53P71326U1VIkrS+7QZdgCRpOBkQkqRWBoQkqZUBIUlqZUBIkloZEJKkVgaEJKmVASFJamVASJJa7TDoArbEnDlzauHChYMuQ5KmlFtvvfWXVTV3Y/06C4gks4DrgZnN53ypqj6QZBFwMTAbuA14a1X9NslM4ELgz4EHgb+uqnvG+4yFCxeyYsWKrlZBkrZJSX4+kX5dDjE9CRxWVQcAS4AjkhwMnAGcWVWLgYeBE5r+JwAPV9XzgTObfpKkAeksIKrn183kjOZRwGHAl5r2C4CjmtdHNtM07786SbqqT5I0vk4PUifZPslKYA1wJfCvwK+qal3TZRSY37yeD6wGaN5/BNijy/okSRvW6UHqqnoKWJJkN+Ay4IVt3Zrntr2FZ12LPMlSYCnAPvvsM0mVSppOfve73zE6OsoTTzwx6FI6NWvWLBYsWMCMGTM2a/6tchZTVf0qybXAwcBuSXZo9hIWAPc13UaBvYHRJDsAuwIPtSxrObAcYGRkxJtZSNpko6Oj7LLLLixcuJBtdSS7qnjwwQcZHR1l0aJFm7WMzoaYksxt9hxIsiPwGmAVcA3wpqbb8cBXm9eXN9M073+nvJuRpA488cQT7LHHHttsOAAkYY899tiivaQu9yDmARck2Z5eEF1SVV9PcidwcZIPAt8Dzmv6nwdclORuensOx3ZYm6RpblsOhzFbuo6dBURV3Q68uKX9p8BBLe1PAMd0VY8kadNM6V9SS9JkOOmDn5/U5Z39X46b1OUNigEhdWQiXzrbyheJhsO6devYYYfJ+1o3ICRpQI466ihWr17NE088wcknn8zSpUs577zzOOOMM9hrr71YvHgxM2fO5Oyzz2bt2rW8853v5N577wXgrLPO4pBDDmHZsmXcd9993HPPPcyZM4fPfe5zk1afASFJA3L++ecze/ZsfvOb33DggQfyhje8gdNOO43bbruNXXbZhcMOO4wDDjgAgJNPPpn3vOc9vPzlL+fee+/lta99LatWrQLg1ltv5YYbbmDHHXec1PoMCLVyeETq3sc//nEuu+wyAFavXs1FF13Eq171KmbPng3AMcccw49//GMArrrqKu68885n5n300Ud57LHHAHjjG9846eEABoQkDcS1117LVVddxY033shOO+3EoYceyr777vvMXsH6nn76aW688cbWIHjuc5/bSY3eMEiSBuCRRx5h9913Z6edduKuu+7ipptu4vHHH+e6667j4YcfZt26dVx66aXP9D/88MM5++yzn5leuXJl5zW6ByFp2hvEcOkRRxzBueeey/7778++++7LwQcfzPz58zn11FN56Utfyl577cV+++3HrrvuCvSGo0488UT2339/1q1bxytf+UrOPffcTms0ILRFPFYhbZ6ZM2fyjW9841ntIyMjLF26lHXr1nH00Udz+OGHAzBnzhy+8IUvPKv/smXLOqvRISZJGiLLli1jyZIlvOhFL2LRokUcddRRG5+pI+5BSNIQ+fCHPzzoEp5hQEgD5jDdYFTVNn/Bvi29ILZDTJKmnVmzZvHggw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m7a5ya5NMktzeOQlmXuAuxfVd9Psl1zP4G5zXvbJbk7yZwNLSvJQUn+pbme/78k2bdp/5skX0zyNeDbSeYlub65vv8dSV7RlHA5cFy3/3KarqbtL6k1Lb29qh5qLhdxS5JLgZnAfwVeAjwGfAf4ftP/Y/TuEXBDkn2Ab/HsC+6N0FzKoKqeTvIZ4C30ru/zGuD7VfXLJJ/bwLLuAl5ZVeuSvAb478BfNct+Gb3weSjJe4FvVdXpzS+ad2o+8+EkM5PsUVUPTu4/l6Y7A0LTybuSHN283htYDPwxcF1VPQSQ5IvAC5o+rwH2613SBoA/SrJLc6+KMfOAtX3T59O7js9ZwNvpXSxtg8sCdqV3GYvF9C4lMqNvWVeO1QXcApzfXMzwK+vdBGYNsBdgQGhSGRCaFpIcSu9L+mVV9XiSa4FZtF/qecx2Tf/fjNPnN81yAKiq1UkeSHIY8FJ6exMbXFaSTwDXVNXR6d0D49q+t/9f33KvT/JKejeHuSjJ/6yqC5u3ZzV1SJPKYxCaLnYFHm7C4U/pXXob4LvAq5Ls3hwM/qu+eb4NnDQ2kfZ7+64Cnr9e26eAz9C7qN1TG1nWrsAvmtd/s6Hik/wJvWv/f5LeheRe0rSH3l7QPRuaV9pcBoSmi28COyS5HTgNuAmgqn5Bb9z/ZuAq4E7gkWaedwEj6d2Z605aropZVXcBuzbDRWMuB3bm98NL4y3rfwD/nOT/AtuPU/+hwMok36MXYh9r2v8cuKnvbmjSpPFqrpr2kuxcVb9u9iAuA86vqss2Yf73AI9V1dg9jkfoHZB+xfhzbrkkHwMur6qru/4sTT/uQUiwrLn/xB3Az4CvbOL85wBPAiQ5hd4d8d4/qRVu2B2Gg7riHoQkqZV7EJKkVgaEJKmVASFJamVASJJaGRCSpFYGhCSp1f8HFA1IPG8S6tMAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Solution\n",
    "\n",
    "hist = thinkstats2.Hist(resp.ager)\n",
    "thinkplot.Hist(hist, label='ager')\n",
    "thinkplot.Config(xlabel='age (years)', ylabel='Count')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Make a histogram of <tt>numfmhh</tt>, the number of people in the respondent's household."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAY8AAAEKCAYAAADq59mMAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvOIA7rQAAGVZJREFUeJzt3X+UXWV97/H3h4CJCgpCcCGBJtioGGiDRETR3gCtIopg64+k+LPVSAvWH6W3Ul0LteJqb1G5FC9eRC5iAYugiL2piIp6vRVDAqwQIFyiRBnJhQi3aP2BJHzvH2dPOEkmk9lhZvZM5v1a66w55znP3vubA3M+s5+997NTVUiS1MYuXRcgSZp8DA9JUmuGhySpNcNDktSa4SFJas3wkCS1ZnhIklozPCRJrRkekqTWdu26gLGyzz771OzZs7suQ5ImjRUrVvy0qmaOpO9OGx6zZ89m+fLlXZchSZNGkh+NtK/DVpKk1gwPSVJrhockqbWd9piHpJ3LI488wsDAAL/+9a+7LmXSmzFjBrNmzWK33Xbb4XUYHpImhYGBAfbYYw9mz55Nkq7LmbSqigceeICBgQHmzJmzw+tx2ErSpPDrX/+avffe2+B4nJKw9957P+49OMND0qRhcIyO0fgcDQ9JUmse85A0KZ32kctHdX3nfWDxqK6vjdWrV7No0SKScOWVV/LMZz5zu8t88IMfZPfdd+f000/frH3t2rW88pWvZNWqVWNVLmB4aARG+5e0jS5/oaXxcvXVV3PiiSfyoQ99qOtSRsxhK0kaobVr13LwwQfz9re/nXnz5vHSl76UX/3qVyxcuHDTdEg//elPGZxX7+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mrZ/JLa1/c9W1RlbbP8kRm7L9Qa4raqm9K1gNTIOW2lnt5beX+gAO3pG0esBkryY3g16HqI3AeY7m9lPSXLYCNbzHeCkZtbUJwOvBv7XCJb7gyRPa47jnAT8b+AbwGuS7Nts/2lJfoveDbf+U3N8ZxqwmN4QFfR+3wc/gz8GvrvFdu4EZqa5j3iS3ZLMG0F9moLc89DO7mzgiiRvBL65g+v4f0n+DXgK8CdN29/SuzPgyiZA1gKvHG4lVXVTkouBZU3ThVW1vSEr6H3Jfw74beCyqloOkOQDwNeS7AI8ApxaVTckOQO4nt6exNKq+nKznl8A85KsAB6iCcW++n7TnLJ7bpKn0vt+OAeYyrNDaxucVVeawJK8BVhQVaeNwrr+o6p2f/xVSQ5bSZJ2gHsekqTW3POQJLVmeEiSWjM8JEmtGR6SpNYMD0lSa4aHJKm1/w/5lCI7/Vr90gAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Solution\n",
    "\n",
    "hist = thinkstats2.Hist(resp.numfmhh)\n",
    "thinkplot.Hist(hist, label='numfmhh')\n",
    "thinkplot.Config(xlabel='number of people', ylabel='Count')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Make a histogram of <tt>parity</tt>, the number of children borne by the respondent.  How would you describe this distribution?"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAY4AAAEKCAYAAAAFJbKyAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvOIA7rQAAFuBJREFUeJzt3X2QXXWd5/H3R4gmQhwQokUe3DBOnAJlBjU8CNYu6g5PtYouMMIgBMoxoGRKV2aq0LEKdiZUzVaJWi4ajIIJijAMwhgYRiYi6uJEJGgWEjIsWUVoQ0HkQWEFx+B3/7inwyV0uvuEvn270+9XVdc953t/59xv37qVT875nXs6VYUkSaP1kn43IEmaXAwOSVIrBockqRWDQ5LUisEhSWrF4JAktWJwSJJaMTgkSa0YHJKkVnbvdwO9sO+++9b8+fP73YYkTSp33nnnL6pq1kjjdsngmD9/PmvXru13G5I0qST52WjGeapKktSKwSFJasXgkCS1skvOcUjScH77298yMDDAM8880+9W+mL69OnMnTuXadOm7dT2BoekKWdgYICZM2cyf/58kvS7nXFVVTz66KMMDAyw//7779Q+PFUlacp55pln2GeffaZcaAAkYZ999nlRR1sGh6QpaSqGxqAX+7sbHJKkVpzjkDTlLVl61Zju75JPnDqm+xvKpZdeystf/nLOOOMMVqxYwdFHH83s2bN7/rpgcAyp7YdoPD4kkjRo69atnHPOOdvWV6xYwRve8AaDQ5J2Zffffz/HHnsshx12GD/+8Y953etexxVXXMEnP/lJbrjhBp5++mmOOOIIvvCFL5CEo446iiOOOILvf//7vOtd7+LJJ59kzz333HaLpdNOO40ZM2Zw0UUX8aUvfYnrr78egNWrV7Ns2TKuu+66MevdOQ5J6pN7772XxYsXc9ddd/GKV7yCz3/+8yxZsoQ77riD9evX8/TTT3PjjTduG//EE0/w3e9+l/POO29b7aSTTmLhwoVceeWVrFu3juOPP56NGzeyZcsWAL785S9z1llnjWnfBock9cm8efM48sgjAXjf+97Hbbfdxq233sphhx3GQQcdxLe//W02bNiwbfx73/veEfeZhNNPP52vfvWrPPHEE6xZs4bjjjtuTPv2VJUk9cn2l8Um4UMf+hBr165l3rx5XHjhhc/7vsUee+wxqv2eddZZvPOd72T69OmcfPLJ7L772P5T7xGHJPXJAw88wJo1awC46qqreOtb3wrAvvvuy1NPPcW11147qv3MnDmTJ598ctv67NmzmT17NkuXLuXMM88c87494pA05fXrysgDDjiAlStXcvbZZ7NgwQI++MEP8vjjj3PQQQ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muWf9H8nYaTRrmfJ+nMeQDbbl+/GfgEnfkPacLwiEN6cTYCi5J8AbiPzh802pvOHVPvp3Nb/tFYAVya5GngLVX1NHAlMKuq7hnrpqUXw6uqpJ3UXFV1YzMJ3ov9XwL8uKou68X+pZ3lEYc0ASW5k858yHn97kXankcckqRWnByXJLVicEiSWjE4JEmtGBySpFYMDklSKwaHJKmV/w/nPX4f1hpEcAAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Solution\n",
    "\n",
    "# This distribution is positive-valued and skewed to the right.\n",
    "\n",
    "hist = thinkstats2.Hist(resp.parity)\n",
    "thinkplot.Hist(hist, label='parity')\n",
    "thinkplot.Config(xlabel='parity', ylabel='Count')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Use Hist.Largest to find the largest values of <tt>parity</tt>."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[(22, 1),\n",
       " (16, 1),\n",
       " (10, 3),\n",
       " (9, 2),\n",
       " (8, 8),\n",
       " (7, 15),\n",
       " (6, 29),\n",
       " (5, 95),\n",
       " (4, 309),\n",
       " (3, 828)]"
      ]
     },
     "execution_count": 36,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Solution\n",
    "\n",
    "hist.Largest(10)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Let's investigate whether people with higher income have higher parity.  Keep in mind that in this study, we are observing different people at different times during their lives, so this data is not the best choice for answering this question.  But for now let's take it at face value.\n",
    "\n",
    "Use <tt>totincr</tt> to select the respondents with the highest income (level 14).  Plot the histogram of <tt>parity</tt> for just the high income respondents."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "i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Hgc9kZl9zVUmdMSCkIVSTEH6d1iSExwP/CcwFPgO8HxgP/Cvw0czMKgT+ldaXCO8CJgAvA88CS4D/AbYAfwz8bmb+dvU+vwF8LDN/Z0R+MGkIHmKSOvM2YHFm/grwQ+BS4LrMPKGa03888L62/hMz89cy8y8GGzJzOdAHzMnMd9C6//rRETG56jIfuGkEfhapIwaE1Jn1mfnNavkW4BTgPRHxSEQ8AZwG/HJb/68NtcNsDd+/AlwQEROBdwP/OLxlS3vPuZikzux8LDaBL9G6K9j6iLgaaL9t5I863O9NwN3AVuDv2s9XSE1zBCF15s1t91I+H3i4Wv5+dS+M8zrcz2Za5yQAyMwNtKaMv4rW+QmpaziCkDqzFpgXEV8GngYWAYcDT9A6+fxoh/tZAlwfEVuAd2fmFuBWYHJmjvZpsNVlvIpJGkJ1FdM91cnoOvZ/HfBYZt5Yx/6lveUIQmpQRKyidb7iiqZrkXbmCEKSVORJaklSkQEhSSoyICRJRQaEJKnIgJAkFRkQkqSi/wdGh0mavUcHJAAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Solution\n",
    "\n",
    "rich = resp[resp.totincr == 14]\n",
    "hist = thinkstats2.Hist(rich.parity)\n",
    "thinkplot.Hist(hist, label='parity')\n",
    "thinkplot.Config(xlabel='parity', ylabel='Count')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Find the largest parities for high income respondents."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 38,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[(8, 1), (7, 1), (5, 5), (4, 19), (3, 123), (2, 267), (1, 229), (0, 515)]"
      ]
     },
     "execution_count": 38,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Solution\n",
    "\n",
    "hist.Largest(10)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Compare the mean <tt>parity</tt> for high income respondents and others."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 39,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(1.0758620689655172, 1.2495758136665125)"
      ]
     },
     "execution_count": 39,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Solution\n",
    "\n",
    "not_rich = resp[resp.totincr < 14]\n",
    "rich.parity.mean(), not_rich.parity.mean()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Compute the Cohen effect size for this difference.  How does it compare with the difference in pregnancy length for first babies and others?"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 40,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "-0.1251185531466061"
      ]
     },
     "execution_count": 40,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Solution\n",
    "\n",
    "# This effect is about 10 times stronger than the difference in pregnancy length.\n",
    "# But remembering the design of the study, we should not make too much of this\n",
    "# apparent effect.\n",
    "\n",
    "CohenEffectSize(rich.parity, not_rich.parity)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.7"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 1
}
